from django.db import models

# Create your models here.


class BookInfo(models.Model):
    # 主键 系统会自动增加
    name=models.CharField(max_length=10)
    pub_date=models.DateField(null=True)
    readcount=models.IntegerField(default=0)
    commentcount=models.IntegerField(default=0)
    is_delete=models.BooleanField(default=False)

    class Meta:
        db_table='bookinfo'

    def __str__(self):
        return self.name



class PeopleInfo(models.Model):

    GENDEL_CHOICE = (
        (0, 'boy'),
        (1, 'girl')
    )
    # (值, 说明)

    name=models.CharField(max_length=10)
    description = models.CharField(max_length=200)
    is_delete = models.BooleanField(default=False)
    # choices 选项 只能从元祖中选取一个, 值 定义元祖
    gender=models.SmallIntegerField(choices=GENDEL_CHOICE,default=0)


    book=models.ForeignKey(BookInfo,on_delete=models.CASCADE)

    class Meta:
        db_table='peopleinfo'


    def __str__(self):
        return self.name